package com.edu.study.base.wordLearn.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.wordLearn.domain.EduWordLearn;
import com.edu.study.base.wordLearn.service.IEduWordLearnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词Controller
 * 
 * @author admin
 * @date 2021-08-04
 */
@RestController
@RequestMapping("/wordLearn/learn")
public class EduWordLearnController extends BaseController
{
    @Autowired
    private IEduWordLearnService eduWordLearnService;

    /**
     * 查询生词库，需要学习的词汇 正在学习的词汇 1、在“目标生词”库中顺序默认100个生词列表
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduWordLearn eduWordLearn)
    {
        startPage();
        List<EduWordLearn> list = eduWordLearnService.selectEduWordLearnList(eduWordLearn);
        return getDataTable(list);
    }

    /**
     * 导出生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词列表
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:export')")
    @Log(title = "生词库，需要学习的词汇 正在学习的词汇 1、在“目标生词”库中顺序默认100个生词", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EduWordLearn eduWordLearn)
    {
        List<EduWordLearn> list = eduWordLearnService.selectEduWordLearnList(eduWordLearn);
        ExcelUtil<EduWordLearn> util = new ExcelUtil<EduWordLearn>(EduWordLearn.class);
        return util.exportExcel(list, "learn");
    }

    /**
     * 获取生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词详细信息
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(eduWordLearnService.selectEduWordLearnById(id));
    }

    /**
     * 新增生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:add')")
    @Log(title = "生词库，需要学习的词汇 正在学习的词汇 1、在“目标生词”库中顺序默认100个生词", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduWordLearn eduWordLearn)
    {
        return toAjax(eduWordLearnService.insertEduWordLearn(eduWordLearn));
    }

    /**
     * 修改生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:edit')")
    @Log(title = "生词库，需要学习的词汇  正在学习的词汇 1、在“目标生词”库中顺序默认100个生词", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduWordLearn eduWordLearn)
    {
        return toAjax(eduWordLearnService.updateEduWordLearn(eduWordLearn));
    }

    /**
     * 删除生词库，需要学习的词汇

正在学习的词汇
1、在“目标生词”库中顺序默认100个生词
     */
    @PreAuthorize("@ss.hasPermi('wordLearn:learn:remove')")
    @Log(title = "生词库，需要学习的词汇 正在学习的词汇 1、在“目标生词”库中顺序默认100个生词", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(eduWordLearnService.deleteEduWordLearnByIds(ids));
    }
}
